package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author nofish.yan@gmail.com
 * @date 2018/4/12.
 * 商场海报数据访问接口
 */
public interface MerchantPosterMapper extends MyMapper<MerchantPoster> {

    /**
     * 导购员的所有商户海报
     *
     * @param employeeId 导购员ID
     * @return 海报集合
     */
    List<MerchantPoster> listByEmployeeId(@Param("employeeId") Integer employeeId);

    /**
     * 根据筛选条件查询商户海报
     *
     * @param merchantPoster 查询条件集合
     * @return 海报集合
     */
    List<MerchantPoster> listAllByFilter(MerchantPoster merchantPoster);

    /**
     * 插入商户海报的所有图片
     *
     * @param merchantPoster 商户海报
     */
    void insertPosterImage(MerchantPoster merchantPoster);

    /**
     * 插入商户海报，并返回ID
     *
     * @param merchantPoster 商户海报
     */
    void insertPosterAndReturnId(MerchantPoster merchantPoster);

    /**
     * 修改商户海报的状态为不可用
     *
     * @param posterId 商户海报ID
     */
    @Select("UPDATE t_merchant_poster SET status = 1 WHERE id = #{posterId}")
    void disablePoster(Integer posterId);

    /**
     * 根据条件查询商场海报管理报表
     */
    List<MerchantPoster> listMerchantPosterManagement(MerchantPoster merchantPoster);

    /**
     * 根据id预览图片
     */
    List<MerchantPoster> findPosterImageByMerchantPosterId(Integer id);

    /**
     * 新增商户海报的标签
     *
     * @param merchantPoster
     */
    void insertPosterTag(MerchantPoster merchantPoster);

    /**
     * 批量插入商户海报维度标签
     * @param merchantPoster 商户海报数据实例
     */
    void insertPoserDimensionTag(MerchantPoster merchantPoster);

    Integer findEmployeeByShopId(Integer shopId);

    List<DailyMerchantPoster> queryOperationDay(Date date);

    List<MonthlyMerchantPoster> queryOperationMonth(Date date);

    List<DailyMerchantPoster> queryPvAndUvDay(Date date);

    List<MonthlyMerchantPoster> queryPvAndUvMonth(Date date);

    Integer findMerchantPosterImageSort(@Param("id") Integer id);

    Integer insertPosterImageUrl(MerchantPosterImage merchantPosterImage);

    Integer findPosterImageNum(@Param("id") Integer id);

    int updateImageStatus(@Param("id") Integer id,@Param("status") Integer status);

    List<Tag> findPosterTag(@Param("posterId") Integer posterId);

    List<DimensionTag> findDimensionTag(@Param("posterId") Integer posterId);

    int updatePoster(MerchantPoster merchantPoster);

    int lowerFramePoster(@Param("id") Integer id);

    Integer findImageCount(@Param("posterId") Integer posterId);

    Integer findTagCount(@Param("posterId") Integer posterId);

    int updateMerchantPosterImage(@Param("posterId") Integer posterId,@Param("imageId") Integer imageId,@Param("status") Integer status);

    int insertMerchantPosterImageTow(@Param("posterId") Integer posterId,@Param("status") Integer status,@Param("imageUrl") String imageUrl);

    int updateMerchantPosterImageStatus(@Param("posterId") Integer posterId,@Param("list") List<Integer> list);

    List<MerchantPosterImage> findMerchantPosterImage(@Param("posterId") Integer posterId);

    List<MerchantPoster> findMerchantPosterVideoByEmployeeId(@Param("employeeId") Integer employeeId);

    List<MerchantPoster> listMerchantPosterVideoByEmployeeId(@Param("employeeId") Integer employeeId);

}
